package com.lagou.rabbit.listener;

import com.lagou.rabbit.config.RabbitMqConfig;
import com.lagou.rabbit.util.OrderUtil;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

/**
 * created by wq at 2020/12/13
 */
@Component
public class PaymentDlxQueueListener {

    @RabbitListener(queues = RabbitMqConfig.orderDelayQueue)
    public void onMessage(Message message) throws UnsupportedEncodingException {
        // 获取订单id
        String id = new String(message.getBody(), "utf-8");
        // 移除订单
        OrderUtil.remove(id);
    }
}
